﻿namespace Framework
{
    public class ReferenceCountable
    {
        public int counter
        {
            get { return _counter; }
        }
        
        protected int _counter = 0;

        public virtual void Retain()
        {
            ++_counter;
        }

        public virtual void Release()
        {
            if (_counter > 0)
            {
                --_counter;
            }
        }

        public bool IsUnused()
        {
            return _counter <= 0;
        }
    }
}